<?php
/*
 * First authored by Brian Cray
 * License: http://creativecommons.org/licenses/by/3.0/
 * Contact the author at http://briancray.com/
 */
define('URLFZ',1);
require_once('config.php');
require_once(SOURCE_DIR .'subs-redirect.php');
require_once(SOURCE_DIR .'subs-sql.php');

$url = utf8_decode($_GET['url']);
verifyURL($url);
$shortened_id = getIDFromShortenedURL($url);
if(CACHE)
{
	$long_url = useCache($shortened_id);
}
else
{
	$long_url = getLong($shortened_id);
}
if(TRACK){
	track($shortened_id);
}
if(empty($long_url))
	writeHeaders(BASE_HREF, 307);
else
writeHeaders($long_url, 301);
?>
